package com.wql.study.designpattern.strategy;

public class Context {
	private static final String PATH;

	static {
		// package com.wql.designpattern.strategy
		PATH = Context.class.getPackage().toString().substring(8);
	}

	private IStrategy strategy;

	public void setStrategy(String strategy) {
		try {
			this.strategy = (IStrategy) Class.forName(PATH + "." + strategy)
					.newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	public void oper() {
		this.strategy.oper();
	}
}
